<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%@ include file="/common/import.jsp" %>
<script>
  var thsTitle = "修改标的";
  var objName = "item";
</script>
<script type="text/javascript" src="${ctx}/js/zbxupload.js"></script> 
</head>
<body>
<!-- 正文开始 -->
<form id="addItemForm">
	<input type="hidden" name="itemId" id="itemId" value="${bidItem.itemId}">
	<input type="hidden" name="bidMode" id="bidMode" value="${bidItem.bidMode}">
	<table class="info" cellspacing="1" cellpadding="0">
		<tr>
			<th>标的名称：</th>
			<td><input type="text" name="itemName"  value="${bidItem.itemName}" size="80" maxlength="200" class="easyui-validatebox validatebox-text" 
			validtype="length[1,60]"	required="true"  missingMessage="请输入标的名称"  
				invalidMessage="最多可输入60中文字符"  title="标的名称最多可输入60中文字符" /> </td>
		</tr>
		<tr>
			<th>特别说明：</th>
			<td><input type="text" name="spare1"  value="${bidItem.spare1}" size="80" maxlength="40" class="easyui-validatebox validatebox-text" 
			validtype="length[1,40]" missingMessage="请输入标的特别说明"  
				invalidMessage="最多可输入40中文字符"  title="标的特别说明最多可输入40中文字符" /> </td>
		</tr>
		<c:if test="${not empty ifGroup && ifGroup =='T' }">
        <tr>
			<th>标的分组：</th>
			<td><input type="text" name="groupId" id="groupIdCombo" value="${bidItem.groupId}" size="80"/> 
			  <input type="hidden" name="groupName" id="groupNameCombo" value="${bidItem.groupName}" />
			</td>
		</tr>
		</c:if>
		<tr>
			<th>标的类型：</th>
			<td><input type="text" name="itemType" id="itemType" value="${bidItem.itemType}" size="80"/> 
			</td>
		</tr>
		<tr>
			<th>货币单位/币种：</th>
			<td>
				<select name="priceUnit" id="priceUnit" value=""><option value="元">元</option><option value="万元">万元</option></select>
				<input name="currency" id="currency" value="" size="10"/>
			</td>
		</tr>
		<tr>
			<th>起始价格：</th>
			<td>
				<input type="text" name="firstValuePre" id="firstValuePre" value="${bidItem.firstValuePre}" size="18" maxlength="20" onchange="changePrice();" onblur="changeDecimal('firstValuePre');" class="easyui-validatebox validatebox-text" 
			validtype="number"	required="true"  missingMessage="请输入起始价格"  invalidMessage="必须为非负的数字"  title="请输入起始价格" /> 
				<select name="decimalCount"  id="decimalCount" value=""><option value="0">0位</option><option value="1">1位</option><option value="2">2位</option><option value="3">3位</option><option value="4">4位</option><option value="5">5位</option><option value="6">6位</option></select><font color="red">(保留小数位)</font>
			</td>
		</tr>
		<tr>
			<th>加价幅度：</th>
			<td>
			<c:choose>
				<c:when test="${fn:contains(bidItem.incrementValue, '|')}"> 
				    请使用<font color="red">"高级规则"--->"阶梯加价幅度"</font>修改！  
				</c:when> 
				<c:otherwise>
				<input type="text" name="incrementValue" id="incrementValue"  value="${bidItem.incrementValue}" size="18" maxlength="50" onchange="changePrice();" onblur="changeDecimal('incrementValue');" class="easyui-validatebox validatebox-text" 
			validtype="number"	required="true"  missingMessage="请输入加价幅度"  invalidMessage="必须为非负的数字"  title="请输入加价幅度"  /> 
				</c:otherwise>
			</c:choose>
			</td>
		</tr>
		
		<c:if test="${bidItem.bidMode != '7'}">
		<tr>
			<th>是否允许报起始价：</th>
			<td>
				<input type="radio" name="allowFirstValue" value="T" <c:if test="${bidItem.allowFirstValue == 'T'}"> checked="checked" </c:if> />是，从起始价<font id="fv1"></font>开始报价，
				<input type="radio" name="allowFirstValue" value="F" <c:if test="${bidItem.allowFirstValue != 'T'}"> checked="checked" </c:if>  />否，从起始价之上一个加价幅度<font id="fv2"></font>开始报价
			</td>
		</tr>
		</c:if>	
		<c:if test="${bidItem.openTimePre != '2050-12-31 23:59:59'}">
		<tr>
			<th>竞价开始时间：</th>
			<td>
			<input type="hidden" name="openTimePre" id="openTimePre" value="" size="20" /> 
				<select class="myDate" id=openTimePre_y></select>年
				<select class="myDate" id=openTimePre_m></select>月
				<select class="myDate" id=openTimePre_d></select>日
				<select class="myTime" id=openTimePre_hh></select>时
				<select class="myTime" id=openTimePre_mm></select>分
				<select class="myTime" id=openTimePre_ss></select>秒
			 </td>
		</tr>
		</c:if>
		<c:if test="${bidItem.bidMode != '7' && bidItem.firstBidTimePre != '2050-12-31 23:59:59'}">
		<tr>
			<th>${(bidItem.bidMode=='1'||bidItem.bidMode=='2')?'限时开始时间':'竞价结束时间'}：</th>
			<td>
				<input type="hidden" name="firstBidTimePre" id="firstBidTimePre" value="" size="20" /> 
				<select class="myDate" id=firstBidTimePre_y></select>年
				<select class="myDate" id=firstBidTimePre_m></select>月
				<select class="myDate" id=firstBidTimePre_d></select>日
				<select class="myTime" id=firstBidTimePre_hh></select>时
				<select class="myTime" id=firstBidTimePre_mm></select>分
				<select class="myTime" id=firstBidTimePre_ss></select>秒
			</td>
		</tr>
		</c:if>	
		
		<c:if test="${bidItem.bidMode == '7'}">
			<input type="hidden" name="firstBidTimePre" id="firstBidTimePre">
		</c:if>
		
		<%-- <c:if test="${bidItem.bidMode == '1' || bidItem.bidMode =='2' || bidItem.bidMode =='7'|| bidItem.bidMode =='5'|| bidItem.bidMode =='6'}"> --%>
		<c:if test="${fn:contains('1,2,5,6,7',bidItem.bidMode)}">
		<tr>
			<th>${(bidItem.bidMode!='7')?'限时报价周期':'荷兰降價价周期'}：</th>
			<td><input type="text" name="limitTime" id="limitTime"  value="${bidItem.limitTime}" size="4" maxlength="4"  class="easyui-validatebox validatebox-text" 
			validtype="number"	required="true"  missingMessage="请输入限时报价周期"  invalidMessage="必须为1~4位非负数字"  title="限时报价周期"  onblur="if(this.value=='') {this.value='60';}"  />（秒） </td>
		</tr>
		</c:if>
		
		<tr>			
			<td colspan="2" style="text-align:center;">
				<a class="easyui-linkbutton" iconCls="icon-add" onclick="editItem();">保存</a>
			</td>
		</tr>
	</table>
	</form>	
<!-- 正文结束 -->
<%//@ include file="/common/top.jsp" %>
<!-- 附件上传iframe元素 -->
<iframe name='uploadIframe' id='uploadIframe' frameborder='0' height='0' width='0'></iframe>
<div id="uploadIframeDefDiv" style="height:0px;" ></div>
<script type="text/javascript">
//附件上传回调方法
function myBack(){}
</script>
</body>
</html>
<script>
function editItem(){
	var itemId = $("#itemId").val();
	setMyTime('openTimePre');
	
	if("${bidItem.bidMode}"=="7"){
		var ot = $("#openTimePre").val();
		$("#firstBidTimePre").val(ot);
	}else{
		setMyTime('firstBidTimePre');
	}
	var fvalue = $('#addItemForm').find("input[name='firstValuePre']").val();
	
	var limitTime = $('#limitTime').val();
	if(limitTime == 0){
		alert("限时报价周期值不能为0！");
		return;
	}
	
	if(limitTime > 10000){
		alert("设置的限时报价周期值过大，请输入10000秒以内的值！");
		return ;
	}
	//alert(itemId);
	editSubmit(objName,itemId,"addItemForm");
}
//更新后回调方法
function editCallBack(flag,objName){
	if(flag=="T"){
		alert("修改成功！");
		window.parent.currentTabListSearch();//调用父类刷新当前tab列表方法
		window.parent.closeItemWindow();
	}else{
		alert("修改失败！");
	}
}

function jsonSelectCallBack(obj,eleId,objName){
	if(eleId =="groupIdCombo"){
	  $("#groupNameCombo").val(obj.text);
	  alert($("#groupNameCombo").val());
	}
}

$(function(){
	  if("${ifGroup}"=="T"){
	   jsonDataSelect("groupIdCombo","group","callBack","sessionId=${bidItem.sessionId}");
	  }
  
      jsonDataSelect("itemType","variety","","","");//初始化标的类型combobox 
     //初始化竞价开始时间控件
	 //$('#openTimePre').datetimebox({});
	  //初始化限时开始时间控件
	 //$('#firstBidTimePre').datetimebox({});
	  
	 createMyTimeOption('openTimePre');
	 if($('#openTimePre')){
	 	initMyTime('openTimePre','${bidItem.openTimePre}');
	 }
	 if("${bidItem.bidMode}" != "7"){
		 if($('#firstBidTimePre')){
	    	createMyTimeOption('firstBidTimePre');
	 		initMyTime('firstBidTimePre','${bidItem.firstBidTimePre}');
		 }
	 }
	 
	$(".datebox :text").attr("readonly","readonly"); 
	 //初始化起始价格单位、币种、小数位
	$("#priceUnit").val('${bidItem.priceUnit}');
	//$("#currency").val('${bidItem.currency}');
	$("#decimalCount").val('${bidItem.decimalCount}');
	var currency="${bidItem.currency}";
	if(currency == ""){
		currency = "CNY";
	}
	loadDiceOneStep("currency","currency","0",'${ctx}',currency);
	
});
//小数位数变化(四舍五入)
function changeDecimal(id){
	var decimalCount = $("#decimalCount").val();
	var val = $('#'+id).val();	
	if(!isNaN(val)){
		 var result = Math.round(val * Math.pow(10, decimalCount)) / Math.pow(10, decimalCount);
		 $('#'+id).val(result);
	}
}
</script>